package player;
import java.util.*;
import ttt.*;

public class HumanPlayer implements Player {
	
	public String toString() {
		return "Human Player";
	}
	
	public Point placeMark(TicTacToe t) {
		Scanner scanner = new Scanner(System.in);
		int row, col;
		
		//System.out.println("You play as: " + t.intToChar(t.getPlayerMark(this)));
		t.drawBoard();
		
		do {
		System.out.println();
		System.out.print("Choose row (0, 1 or 2): ");
		row = scanner.nextInt();
		
		System.out.print("Choose column (0, 1 or 2): ");
		System.out.println();
		col = scanner.nextInt();
		} while(!isLegal(row) || !isLegal(col) || t.isOccupied(row, col));
		
		return new Point(row, col);
	}
	
	private boolean isLegal(int i) {
		return (i < 3 && i >= 0);
	}
}
